package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotRoomLog;
import com.gaohe.hotal.service.IHotRoomLogService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 房间日志Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/log")
public class HotRoomLogController extends BaseController
{
    @Autowired
    private IHotRoomLogService hotRoomLogService;

    /**
     * 查询房间日志列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotRoomLog hotRoomLog)
    {
        startPage();
        List<HotRoomLog> list = hotRoomLogService.selectHotRoomLogList(hotRoomLog);
        return getDataTable(list);
    }

    /**
     * 导出房间日志列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:log:export')")
    @Log(title = "房间日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotRoomLog hotRoomLog)
    {
        List<HotRoomLog> list = hotRoomLogService.selectHotRoomLogList(hotRoomLog);
        ExcelUtil<HotRoomLog> util = new ExcelUtil<HotRoomLog>(HotRoomLog.class);
        util.exportExcel(response, list, "房间日志数据");
    }

    /**
     * 获取房间日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:log:query')")
    @GetMapping(value = "/{roomLogId}")
    public AjaxResult getInfo(@PathVariable("roomLogId") Long roomLogId)
    {
        return success(hotRoomLogService.selectHotRoomLogByRoomLogId(roomLogId));
    }

    /**
     * 新增房间日志
     */
    @PreAuthorize("@ss.hasPermi('hotal:log:add')")
    @Log(title = "房间日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotRoomLog hotRoomLog)
    {
        return toAjax(hotRoomLogService.insertHotRoomLog(hotRoomLog));
    }

    /**
     * 修改房间日志
     */
    @PreAuthorize("@ss.hasPermi('hotal:log:edit')")
    @Log(title = "房间日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotRoomLog hotRoomLog)
    {
        return toAjax(hotRoomLogService.updateHotRoomLog(hotRoomLog));
    }

    /**
     * 删除房间日志
     */
    @PreAuthorize("@ss.hasPermi('hotal:log:remove')")
    @Log(title = "房间日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomLogIds}")
    public AjaxResult remove(@PathVariable Long[] roomLogIds)
    {
        return toAjax(hotRoomLogService.deleteHotRoomLogByRoomLogIds(roomLogIds));
    }
}
